package com.logistica.metropolitana.web.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.logistica.metropolitana.common.exception.LogisticaMetropolitanaException;
import com.logistica.metropolitana.common.web.BaseController;

@Controller
public class AppErrorController extends BaseController {

	private final Logger logger = LoggerFactory.getLogger(AppErrorController.class);
	
	@RequestMapping(value="logisticaMetropolitanaError", method = RequestMethod.GET)	
	public String showErrorCodeGet(ModelMap modelMap, HttpServletRequest request, HttpSession session){
		logger.info("Error Message");
		LogisticaMetropolitanaException lMetropolitanaException = 
				(LogisticaMetropolitanaException) session.getAttribute(CUSTOM_EXCEPTION); 
		modelMap.addAttribute(CUSTOM_EXCEPTION, lMetropolitanaException);
		
		return "redirect:/home.html#ajax/errorInterno.html";
	}
	
	@RequestMapping(value="ajax/errorInterno", method = RequestMethod.GET)	
	public String showErrorCodePost(HttpServletRequest request, 
			ModelMap modelMap, HttpSession session){		
		return "errorInterno";
	}
}
